package com.aletto.general_store.ui;

import android.graphics.Rect;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.aletto.general_store.GeneralStoreApplication;
import com.google.android.flexbox.FlexboxLayoutManager;

import me.jessyan.autosize.utils.AutoSizeUtils;

public class HotSearchItemDecoration extends RecyclerView.ItemDecoration {

    private final int
            mLeftSpace   = AutoSizeUtils.dp2px(GeneralStoreApplication.sInstance, 8),
            mBottomSpace = AutoSizeUtils.dp2px(GeneralStoreApplication.sInstance, 5);

    @Override
    public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
                               @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {

        outRect.right = mLeftSpace;

        RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
        if (layoutManager instanceof FlexboxLayoutManager) {
            outRect.bottom = mBottomSpace;
        }

    }

}
